﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Account.Master" AutoEventWireup="true"
    CodeBehind="FriendnFamily.aspx.cs" ValidateRequest="false" Inherits="FrenzDenWebSite.FriendnFamilyForm" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="panelContent" runat="server">
    <fieldset class="ui-corner-all" style="background-color: White; border: 1px slid black;
        padding: 10px;">
        <script type="text/javascript">
            $(document).ready(function () {
                $("#ctl00_panelContent_txtRelatedTo").fcbkcomplete({
                    json_url: "FdService.asmx/GetProfiles",
                    addontab: true,
                    maxitems: 1,
                    input_min_size: 2,
                    height: 10,
                    width: 190,
                    cache: false,
                    newel: false,
                    select_all_text: ""
                });
            });

            $(document).ready(function () {
                $("#ctl00_panelContent_txtFamilyProfile").fcbkcomplete({
                    json_url: "FdService.asmx/GetProfiles",
                    addontab: true,
                    maxitems: 1,
                    input_min_size: 2,
                    height: 10,
                    width: 190,
                    cache: false,
                    newel: false,
                    select_all_text: ""
                });
            });

            function ClearHiddenFieldItem(itemId) {
                document.getElementById('<%=hfRelatedTo.ClientID %>').value = "";
                document.getElementById('<%=hfFamilyProfile.ClientID %>').value = "";
            }

            function AddItemToHiddenField(itemId) {
                document.getElementById('<%=hfRelatedTo.ClientID %>').value = itemId;
                document.getElementById('<%=hfFamilyProfile.ClientID %>').value = itemId;
            }

            function ToggleRelationship(ctl) {
                if (ctl.value == "1" || ctl.value == "5" || ctl.value == "6" || ctl.value == "7") {
                    document.getElementById("<%=trRelation.ClientID %>").style.display = "none";
                }
                else {
                    document.getElementById("<%=trRelation.ClientID %>").style.display = "block";
                }

            }

            function getCookie(c_name) {
                var i, x, y, ARRcookies = document.cookie.split(";");
                for (i = 0; i < ARRcookies.length; i++) {
                    x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("="));
                    y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1);
                    x = x.replace(/^\s+|\s+$/g, "");
                    if (x == c_name) {
                        return unescape(y);
                    }
                }
            }

            $(document).ready(function () {
                var profileId = getCookie("fduserprofileid");
                ob_post.AddParam('profileId', profileId);
                var result = ob_post.post(null, 'GetRelatedProfile').split('/');
                //addItem(result[0], result[1], 0, 0, 1);

            });

            function SaveData() {
                var profileId = getCookie("fduserprofileid");
                var relatedProfileID = 0;
                var ctl = document.getElementById('<%=ddlRelationStatus.ClientID %>');
                if (ctl.value == "2" || ctl.value == "3" || ctl.value == "4") {
                    if (document.getElementById('<%=hfRelatedTo.ClientID %>').value != "") {
                        relatedProfileID = document.getElementById('<%=hfRelatedTo.ClientID %>').value;
                    }
                }
                ob_post.AddParam('profileID', profileId);
                ob_post.AddParam('relationshipStatusId', document.getElementById('<%=ddlRelationStatus.ClientID %>').value);
                ob_post.AddParam('relationshipPrivacy', document.getElementById('<%=ddlRelationshipPrivacy.ClientID %>').value);
                ob_post.AddParam('relatedProfileID', relatedProfileID);
                ob_post.AddParam('familyPrivacy', document.getElementById('<%=ddlFamilyPrivacy.ClientID %>').value);
                ob_post.AddParam('friendPrivacy', document.getElementById('<%=ddlFriendPrivacy.ClientID %>').value);
                document.getElementById('msgboxpanel').innerHTML = ob_post.post(null, 'SaveData');
            }
        </script>
        <div id="msgboxpanel">
        </div>
        <table style="width: 100%;">
            <tr>
                <td style="width: 120px">
                    <span class="labelcls">Relationship Status:</span>
                </td>
                <td style="width: 320px">
                    <asp:DropDownList ID="ddlRelationStatus" AutoPostBack="false" CssClass="ddlcls ui-widget-content ui-corner-all"
                        runat="server" OnSelectedIndexChanged="ddlRelationStatus_SelectedIndexChanged"
                        onchange="ToggleRelationship(this)">
                        <asp:ListItem Value=""></asp:ListItem>
                        <asp:ListItem Value="1">Single</asp:ListItem>
                        <asp:ListItem Value="2">In a relationship</asp:ListItem>
                        <asp:ListItem Value="3">Engaged</asp:ListItem>
                        <asp:ListItem Value="4">Married</asp:ListItem>
                        <asp:ListItem Value="5">Divorced</asp:ListItem>
                        <asp:ListItem Value="6">Seperated</asp:ListItem>
                        <asp:ListItem Value="7">Widowed</asp:ListItem>
                    </asp:DropDownList>
                </td>
                <td style="width: 120px">
                    <asp:DropDownList ID="ddlRelationshipPrivacy" CssClass="ddlcls ui-widget-content ui-corner-all"
                        runat="server">
                        <asp:ListItem Value="1">Public</asp:ListItem>
                        <asp:ListItem Value="2">Friends</asp:ListItem>
                        <asp:ListItem Value="3">Private</asp:ListItem>
                    </asp:DropDownList>
                </td>
            </tr>
            <tr id="trRelation" runat="server" style="display: block;">
                <td style="width: 120px">
                    with
                </td>
                <td style="width: 320px">
                    <asp:TextBox ID="txtRelatedTo" runat="server"></asp:TextBox>
                    <asp:HiddenField ID="hfRelatedTo" runat="server" />
                </td>
                <td style="width: 120px">
                    &nbsp;
                </td>
            </tr>
            <tr>
                <td colspan="3">
                    <hr />
                </td>
            </tr>
            <tr>
                <td style="width: 120px">
                    <span class="labelcls">Family:</span>
                </td>
                <td style="width: 320px">
                    <asp:UpdatePanel ID="pnlUpdateFamily" runat="server" UpdateMode="Conditional">
                        <ContentTemplate>
                            <asp:Panel ID="pnlAddCollege" runat="server">
                                <fieldset class="ui-corner-all" style="background-color: White; border: 1px slid black;
                                    padding: 10px; width: 300px; height: 170px; float: left; font-size: 11px;">
                                    <label style="font-size: 12px; font-weight: bold;">
                                        Add Family</label>
                                    <hr />
                                    <table>
                                        <tr>
                                            <td>
                                                <span>* Name:</span>
                                            </td>
                                            <td>
                                                <asp:TextBox ID="txtFamilyProfile" runat="server"></asp:TextBox>
                                                <asp:HiddenField ID="hfFamilyProfile" runat="server" />
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                <span>* Relation:</span>
                                            </td>
                                            <td>
                                                <asp:DropDownList ID="ddlFamilyRelation" runat="server">
                                                </asp:DropDownList>
                                            </td>
                                        </tr>
                                    </table>
                                    <br />
                                    <asp:Button ID="btnCancelFamily" runat="server" Text="Cancel" CssClass="msg_button_class"
                                        Style="float: right;" />
                                    <asp:Button ID="btnAddFamily" ValidationGroup="family1" runat="server" Text="Save"
                                        CssClass="msg_button_class" Style="float: right;" OnClick="btnAddFamily_Click" />
                                    <asp:RequiredFieldValidator ID="rfvFamilyProfile" runat="server" ControlToValidate="txtFamilyProfile"
                                        ValidationGroup="family" Display="None" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>
                                    <asp:RequiredFieldValidator ID="rfvFamilyRelation" runat="server" ControlToValidate="ddlFamilyRelation"
                                        ValidationGroup="family" Display="None" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>
                                    <asp:ValidatorCalloutExtender ID="rfvFamilyRelation_ValidatorCalloutExtender" runat="server"
                                        Enabled="True"  TargetControlID="rfvFamilyRelation">
                                    </asp:ValidatorCalloutExtender>
                                </fieldset>
                            </asp:Panel>
                            <asp:DataList ID="GridFamilyList" runat="server">
                                <ItemTemplate>
                                    <div style="width: 300px">
                                        <span style="font-weight: bold; font-size: 13px;">
                                            <%# DataBinder.Eval(Container.DataItem, "FullName")%></span>
                                        <br />
                                        <span style="font-size: 11px;">
                                            <%# DataBinder.Eval(Container.DataItem, "Title")%>
                                        </span>
                                        <asp:ImageButton ID="imgDeleteFamily" Style="float: right;" pid='<%# DataBinder.Eval(Container.DataItem, "ProfileFamilyID")%>'
                                            ImageUrl="~/images/Close-icon.png" runat="server" OnClick="imgDeleteFamily_Click" />
                                        <hr />
                                    </div>
                                </ItemTemplate>
                            </asp:DataList>
                            <asp:ModalPopupExtender ID="modalAddFamily" runat="server" BackgroundCssClass="modalPopup"
                                TargetControlID="lnkAddFamily" PopupControlID="pnlAddCollege" />
                            <asp:LinkButton ID="lnkAddFamily" runat="server">Add Family</asp:LinkButton>
                        </ContentTemplate>
                        <Triggers>
                            <asp:AsyncPostBackTrigger ControlID="btnAddFamily" EventName="Click" />
                        </Triggers>
                    </asp:UpdatePanel>
                    <asp:UpdateProgress ID="updateProgressFamily" runat="server" AssociatedUpdatePanelID="pnlUpdateFamily">
                        <ProgressTemplate>
                            <div style="position: fixed; height: 100%; width: 100%; top: 0px; left: 0px; background-color: #000000;
                                filter: alpha(opacity=55); -moz-opacity: .55; opacity: .55; z-index: 50;" id="pagedimmer">
                                &nbsp;</div>
                            <div style="position: fixed; background-color: #888888; border: 1px solid #999999;
                                z-index: 50; left: 50%; right: 50%; top: 50%; width: 25px;" id="msgbox">
                                <div>
                                    <img src="ajax-loader.gif" alt="loading" />
                                </div>
                            </div>
                        </ProgressTemplate>
                    </asp:UpdateProgress>
                </td>
                <td style="width: 120px">
                    <asp:DropDownList ID="ddlFamilyPrivacy" CssClass="ddlcls ui-widget-content ui-corner-all"
                        runat="server">
                        <asp:ListItem Value="1">Public</asp:ListItem>
                        <asp:ListItem Value="2">Friends</asp:ListItem>
                        <asp:ListItem Value="3">Private</asp:ListItem>
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td colspan="3">
                    <hr />
                </td>
            </tr>
            <tr>
                <td style="width: 120px">
                    <span class="labelcls">Friends:</span>
                </td>
                <td style="width: 320px">
                    <asp:LinkButton ID="lnkFriends" runat="server">120 Friends</asp:LinkButton>
                </td>
                <td style="width: 120px">
                    <asp:DropDownList ID="ddlFriendPrivacy" CssClass="ddlcls ui-widget-content ui-corner-all"
                        runat="server">
                        <asp:ListItem Value="1">Public</asp:ListItem>
                        <asp:ListItem Value="2">Friends</asp:ListItem>
                        <asp:ListItem Value="3">Private</asp:ListItem>
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td colspan="3">
                    <hr />
                </td>
            </tr>
            <tr>
                <td style="width: 120px">
                    &nbsp;
                </td>
                <td style="width: 320px">
                    &nbsp;
                </td>
                <td style="width: 120px">
                    <asp:Button ID="btnSave" runat="server" CssClass="btncls" Text="Save Changes" OnClick="btnSave_Click"
                        OnClientClick="SaveData(); return false;" />
                </td>
            </tr>
        </table>
    </fieldset>
</asp:Content>
